#include "Header.h"

class Eight
{
	void Calculate()
	{

	}

};

class Seven
{
public:

	void Calculate()
	{
		int count = 0;
		int num = 2;

		while (count != 10001)
		{
			if (isPrime(num))
			{
				count++;
				cout << count << endl;
				
			}
			num++;
		}

		cout << num - 1 << endl;
	}

	bool isPrime(int num)
	{
		for (int i = 2; i <= num/2; i++)
		{
			if (num % i == 0)
				return false;
		}

		return true;
	}

};

class Six
{
public:
	void Calculate()
	{
		const int num = 100;

		int64 squares = 0;
		int64 sum = 0;
		
		for (int i = 1; i <= num; i++)
		{
			sum += i;
		}

		sum = sum * sum;

		for (int i = 1; i <= num; i++)
		{
			squares += i * i;
		}

		cout << squares - sum << endl;
	}

};

class Five
{
public:
	void Calculate()
	{
		int64 start = 2520;
		int64 num = 20;
		int64 count = 1;
		for (int i = 1; i <= num; i++)
		{
			list.push_back(i);
		}

		while ( isDivisible(num) == false)
		{
			cout << num << " failed" << endl;
			count++;
			num = start * count;
			
		}

		cout << num << endl;

		
	}

	bool isDivisible(int num)
	{
		bool ans = true;
		for (int i = 0; i < list.size(); i++)
		{
			if (num % list[i] != 0)
			{
				ans = false;
			}
		}

		return ans;
	}

private:
	vector<int> list;
};

class Four
{

public:
	void Calculate()
	{
		int ans = 0;
		int num1 = 0;
		int num2 = 0;
		int product = 0;
		string product_string = ToString(product);

		for (int i = 0; i < 1000; i++)
		{
			for (int j = 0; j < 1000; j++)
			{
				product = i * j;
				product_string = ToString(product);
				if (IsPalin(product_string))
				{
					if (product > ans)
					{
						ans = product;
						num1 = i;
						num2 = j;
					}
				}
			}
		}

		cout << ans << " " << num1 << " " << num2 << endl;
	}

	string ToString(int num)
	{
		string s = to_string(num);
		return s;
	}

	bool IsPalin(string s)
	{
		int start = 0;
		int end = s.size() - 1;
		bool ans = false;

		while ( (start != end) && (start < end) )
		{
			if (s[start] != s[end])
			{
				return ans;
				break;
			}
			start++;
			end--;
		}

		ans = true;
		return ans;
	}
};

class Three
{
	
public:

	void Calculate()
	{
		int64 num = 600851475143;
		int remainder = 0;
		int divider = 2;

		while ( (num / 2) != divider && (num / 2) > divider)
		{
			if (num % divider == 0)
			{
				num = num / divider;
			}
			else
			{
				divider++;
			}
		}

		cout << num << endl;
		

	}

};